home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / newsxd / part03 < prev    next >
Encoding:
Internet Message Format  |  1990-10-09  |  28.8 KB

  1. Subject:  v23i013:  Netnews transmission daemon, Part03/03
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 88e5ed39 6213c6c6 06153b9e e1133565
  5.  
  6. Submitted-by: Chris Myers <chris@wugate.wustl.edu>
  7. Posting-number: Volume 23, Issue 13
  8. Archive-name: newsxd/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  Makefile complex.conf log.c main.c newsxd.conf newsxd.h
  17. # Wrapped by rsalz@litchi.bbn.com on Fri Jul 13 15:03:58 1990
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. echo If this archive is complete, you will see the following message:
  20. echo '          "shar: End of archive 3 (of 3)."'
  21. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'Makefile'\"
  23. else
  24.   echo shar: Extracting \"'Makefile'\" \(4951 characters\)
  25.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  26. X# 1. If the compiler complains about undefined structs, try removing the
  27. X#    -DBSD4_2 in CFLAGS, below.
  28. X#
  29. X# 2. If the linker complains that it can't find 'index', change -DSTRCHR=index
  30. X#    to -DSTRCHR=strchr in CFLAGS, below.
  31. X
  32. XCFLAGS=        -O -DBSD4_2 -DSTRCHR=index
  33. XLINTFLAGS=    -abchx
  34. XCC=        cc
  35. XLIBS=        -lcnews
  36. X
  37. X# The uid and gid that newsxd (and the news transmitters) should run as
  38. XOWNER=news
  39. XGROUP=news
  40. X
  41. X# Where to put newsxd when it's compiled
  42. XBINDIR=/usr/local/etc
  43. X
  44. X# Where to put the manpage and the manual section it's going into
  45. XMANDIR=/usr/man/manl
  46. XMANEXT=l
  47. X
  48. XSRCS=    config.c log.c main.c process.c util.c
  49. XOBJS=    config.o log.o main.o process.o util.o
  50. X
  51. Xall: newsxd
  52. X
  53. Xnewsxd: ${OBJS}
  54. X    ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
  55. X
  56. Xclean:
  57. X    rm -f ${OBJS} newsxd core
  58. X
  59. Xdepend: ${SRCS}
  60. X    mkdep ${CFLAGS} ${SRCS}
  61. X
  62. Xinstall: newsxd newsxd.8
  63. X    install -c -m 444 -o root -g staff newsxd.8 ${MANDIR}/newsxd.${MANEXT}
  64. X    install -s -c -m 6755 -o ${OWNER} -g ${GROUP} newsxd ${BINDIR}
  65. X
  66. Xshar:
  67. X    shar README Makefile *.c *.h *.conf newsxd.8 > newsxd.shar
  68. X
  69. Xlint: ${SRCS}
  70. X    lint ${LINTFLAGS} ${CFLAGS} ${SRCS}
  71. X
  72. X# DO NOT DELETE THIS LINE -- mkdep uses it.
  73. X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
  74. X
  75. Xconfig.o: config.c defs.h /usr/include/stdio.h /usr/include/signal.h
  76. Xconfig.o: /usr/include/strings.h /usr/include/syslog.h /usr/include/nlist.h
  77. Xconfig.o: /usr/include/errno.h /usr/include/ctype.h /usr/include/sys/param.h
  78. Xconfig.o: /usr/include/machine/param.h /usr/include/signal.h
  79. Xconfig.o: /usr/include/sys/types.h /usr/include/sys/errno.h
  80. Xconfig.o: /usr/include/sys/file.h /usr/include/sys/types.h
  81. Xconfig.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
  82. Xconfig.o: /usr/include/sys/ttydev.h /usr/include/sys/ttyio.h
  83. Xconfig.o: /usr/include/sgtty.h /usr/include/sys/wait.h /usr/include/sys/types.h
  84. Xconfig.o: /usr/include/sys/stat.h newsxd.h patchlevel.h /usr/include/time.h
  85. Xconfig.o: /usr/include/sys/resource.h /usr/include/sys/../h/fixpoint.h
  86. Xlog.o: log.c defs.h /usr/include/stdio.h /usr/include/signal.h
  87. Xlog.o: /usr/include/strings.h /usr/include/syslog.h /usr/include/nlist.h
  88. Xlog.o: /usr/include/errno.h /usr/include/ctype.h /usr/include/sys/param.h
  89. Xlog.o: /usr/include/machine/param.h /usr/include/signal.h
  90. Xlog.o: /usr/include/sys/types.h /usr/include/sys/errno.h
  91. Xlog.o: /usr/include/sys/file.h /usr/include/sys/types.h
  92. Xlog.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
  93. Xlog.o: /usr/include/sys/ttydev.h /usr/include/sys/ttyio.h /usr/include/sgtty.h
  94. Xlog.o: /usr/include/sys/wait.h /usr/include/sys/types.h /usr/include/sys/stat.h
  95. Xlog.o: newsxd.h patchlevel.h /usr/include/time.h /usr/include/sys/resource.h
  96. Xlog.o: /usr/include/sys/../h/fixpoint.h
  97. Xmain.o: main.c defs.h /usr/include/stdio.h /usr/include/signal.h
  98. Xmain.o: /usr/include/strings.h /usr/include/syslog.h /usr/include/nlist.h
  99. Xmain.o: /usr/include/errno.h /usr/include/ctype.h /usr/include/sys/param.h
  100. Xmain.o: /usr/include/machine/param.h /usr/include/signal.h
  101. Xmain.o: /usr/include/sys/types.h /usr/include/sys/errno.h
  102. Xmain.o: /usr/include/sys/file.h /usr/include/sys/types.h
  103. Xmain.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
  104. Xmain.o: /usr/include/sys/ttydev.h /usr/include/sys/ttyio.h /usr/include/sgtty.h
  105. Xmain.o: /usr/include/sys/wait.h /usr/include/sys/types.h
  106. Xmain.o: /usr/include/sys/stat.h newsxd.h patchlevel.h /usr/include/time.h
  107. Xmain.o: /usr/include/sys/resource.h /usr/include/sys/../h/fixpoint.h
  108. Xprocess.o: process.c defs.h /usr/include/stdio.h /usr/include/signal.h
  109. Xprocess.o: /usr/include/strings.h /usr/include/syslog.h /usr/include/nlist.h
  110. Xprocess.o: /usr/include/errno.h /usr/include/ctype.h /usr/include/sys/param.h
  111. Xprocess.o: /usr/include/machine/param.h /usr/include/signal.h
  112. Xprocess.o: /usr/include/sys/types.h /usr/include/sys/errno.h
  113. Xprocess.o: /usr/include/sys/file.h /usr/include/sys/types.h
  114. Xprocess.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
  115. Xprocess.o: /usr/include/sys/ttydev.h /usr/include/sys/ttyio.h
  116. Xprocess.o: /usr/include/sgtty.h /usr/include/sys/wait.h
  117. Xprocess.o: /usr/include/sys/types.h /usr/include/sys/stat.h newsxd.h
  118. Xprocess.o: patchlevel.h /usr/include/time.h /usr/include/sys/resource.h
  119. Xprocess.o: /usr/include/sys/../h/fixpoint.h
  120. Xutil.o: util.c defs.h /usr/include/stdio.h /usr/include/signal.h
  121. Xutil.o: /usr/include/strings.h /usr/include/syslog.h /usr/include/nlist.h
  122. Xutil.o: /usr/include/errno.h /usr/include/ctype.h /usr/include/sys/param.h
  123. Xutil.o: /usr/include/machine/param.h /usr/include/signal.h
  124. Xutil.o: /usr/include/sys/types.h /usr/include/sys/errno.h
  125. Xutil.o: /usr/include/sys/file.h /usr/include/sys/types.h
  126. Xutil.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
  127. Xutil.o: /usr/include/sys/ttydev.h /usr/include/sys/ttyio.h /usr/include/sgtty.h
  128. Xutil.o: /usr/include/sys/wait.h /usr/include/sys/types.h
  129. Xutil.o: /usr/include/sys/stat.h newsxd.h patchlevel.h /usr/include/time.h
  130. Xutil.o: /usr/include/sys/resource.h /usr/include/sys/../h/fixpoint.h
  131. Xversion.o: version.c
  132. X
  133. X# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
  134. END_OF_FILE
  135.   if test 4951 -ne `wc -c <'Makefile'`; then
  136.     echo shar: \"'Makefile'\" unpacked with wrong size!
  137.   fi
  138.   # end of 'Makefile'
  139. fi
  140. if test -f 'complex.conf' -a "${1}" != "-c" ; then 
  141.   echo shar: Will not clobber existing file \"'complex.conf'\"
  142. else
  143.   echo shar: Extracting \"'complex.conf'\" \(3224 characters\)
  144.   sed "s/^X//" >'complex.conf' <<'END_OF_FILE'
  145. X# Define a series of service classes for sending news to other sites:
  146. X#     nlink     NNTPlink Transmits (Continuous NNTPXMITs)
  147. X#     high      High Priority Transmits (Top-40)
  148. X#     med       Medium Prio Transmits (Non Top-40)
  149. X#     low       Low Priority Transmits (Endnodes)
  150. X#     batch     Batched (with sendbatch) newsfeeds
  151. X
  152. Xclass   nlink   maxxmits=20 interval=60    maxload=10  noworkfile
  153. Xxmit    nlink   /usr/local/lib/news/nntplink nntplink %h:%b
  154. X
  155. Xclass   high    maxxmits=99 interval=60/20 maxload=8   ttl=1800
  156. X
  157. Xclass   med     maxxmits=5  interval=300   maxload=6   ttl=1800/60
  158. X
  159. Xclass   low     maxxmits=3  interval=1200  maxload=5   ttl=1100/60   nice=10
  160. X
  161. Xclass   batch   maxxmits=1  interval=3600  maxload=5   ttl=1800/1800
  162. Xxmit    batch   /usr/local/lib/news/sendbatch sendbatch %f %h
  163. X
  164. X# Define the default news transmitter
  165. Xxmit    DEFAULT /usr/local/lib/news/nntpxmit nntpxmit %h:%w
  166. X
  167. X# Check the transmit queue every <n> seconds (this should be at least as
  168. X# low as the smallest "interval" in all of the transmission classes).
  169. Xqueueinterval    20
  170. X
  171. X# In all of the following options, %s is replaced by the host name of the
  172. X# system being sent to.
  173. X
  174. X# File news places articles paths/ids in
  175. Xbatchfile   /usr/spool/batch/%s
  176. X
  177. X# File a news transmitter wants articles paths/ids in
  178. Xworkfile    /usr/spool/batch/%s.work
  179. X
  180. X# Where to log the output of a news transmitter (default is /dev/null)
  181. X# [leave it as the default of /dev/null for now]
  182. X# nntplogs   /usr/spool/batch/%s.log
  183. X
  184. X# Hosts to send news to.  Each line is of the format:
  185. X#                            CLASS   VALID START
  186. X# host HOSTNAME              NAME       TIMES          OPTIONS
  187. X
  188. Xhost dorothy                 low     Any
  189. Xhost toto                    low     Any
  190. Xhost wizard                  low     Any
  191. Xhost witch                   low     Any
  192. Xhost tinman                  low     Any
  193. Xhost lion                    low     Any
  194. Xhost cactus.biz.com          low     Any
  195. Xhost endnode.foobar.edu      low     Any2000-0500
  196. Xhost biggernode.foobar.edu   med     SaSu|Wk1730-0730
  197. Xhost bignode.company.com     med     Any
  198. Xhost midsize.company.com     med     Any
  199. Xhost university.podunk.edu   med     Any
  200. Xhost mrbackbone.bigu.edu     high    Any
  201. Xhost gateway.bizness.com     high    Any
  202. Xhost supernews.hellou.edu    high    Any
  203. Xhost mrnntp.aloha.edu        high    Any
  204. Xhost hello.world.edu         high    Any
  205. Xhost supernews.foou.edu      nlink   Any
  206. Xhost backbone.newssite.edu   nlink   Any
  207. Xhost fred                    batch   Any nice=20 flags=-s500000 interval=86400
  208. Xhost barney                  batch   Any nice=20 flags=-s250000 interval=86400
  209. Xhost wilma                   batch   Any nice=20 flags=-s500000
  210. Xhost betty                   batch   Any nice=20 flags=-s500000|-m500000
  211. Xhost kitty                   batch   SaSu|Wk1730-730 flags=-c|-s250000
  212. Xhost dino                    batch   SaSu|Wk1730-730 flags=-c|-s250000
  213. Xhost bambam                  batch   Sa interval=86400
  214. X
  215. X# Notes: Only send news to biggernode.foobar.edu during non-business hours
  216. X#        endnode.foobar.edu only wants news transmitted from 8PM to 5AM.
  217. X#        Only send news to fred and barney once per day (every 24 hours).
  218. X#        Do one batching run for bambam each Saturday.
  219. END_OF_FILE
  220.   if test 3224 -ne `wc -c <'complex.conf'`; then
  221.     echo shar: \"'complex.conf'\" unpacked with wrong size!
  222.   fi
  223.   # end of 'complex.conf'
  224. fi
  225. if test -f 'log.c' -a "${1}" != "-c" ; then 
  226.   echo shar: Will not clobber existing file \"'log.c'\"
  227. else
  228.   echo shar: Extracting \"'log.c'\" \(5400 characters\)
  229.   sed "s/^X//" >'log.c' <<'END_OF_FILE'
  230. X/*
  231. X * #include <legal/bs.h>
  232. X >
  233. X > Copyright (c) 1989 Washington University in Saint Louis, Missouri and
  234. X > Chris Myers. All rights reserved.
  235. X >
  236. X > Permission is hereby granted to copy, reproduce, redistribute or
  237. X > otherwise use this software as long as: (1) there is no monetary
  238. X > profit gained specifically from the use or reproduction of this
  239. X > software, (2) it is not sold, rented, traded, or otherwise marketed,
  240. X > (3) the above copyright notice and this paragraph is included
  241. X > prominently in any copy made, and (4) that the name of the University
  242. X > is not used to endorse or promote products derived from this software
  243. X > without the specific prior written permission of the University.
  244. X > THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  245. X > IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  246. X > WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  247. X >
  248. X */
  249. X
  250. X#include "defs.h"
  251. X
  252. X/*************************************************************************/
  253. X/* FUNCTION  : log                                                       */
  254. X/* PURPOSE   : Log messages to syslog or a log file, as defined in       */
  255. X/*             newsxd.h.  If debug or DEBUG is set, log to stderr.       */
  256. X/* ARGUMENTS : Log priority, message to log, and message parameters      */
  257. X/*************************************************************************/
  258. X
  259. Xvoid
  260. Xlog(priority, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS2*/
  261. X    int  priority;
  262. X    char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10;
  263. X
  264. X{
  265. Xstatic  FILE    *logfile = NULL;
  266. Xlong    clock;
  267. Xextern  int     errno;
  268. Xchar    buffer[30];
  269. X
  270. X   if ((debug > 0) || (DEBUG > 0)) {
  271. X      (void) fprintf(stderr, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  272. X      return;
  273. X   }
  274. X
  275. X#if     defined(SYSLOG)
  276. X   syslog(priority, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  277. X#endif
  278. X
  279. X#if     defined(FAKESYSLOG)
  280. X   if ((logfile != NULL) && (CONFIGCHANGEDFILE)) {
  281. X       (void) fclose(logfile);
  282. X       logfile = NULL;
  283. X       CONFIGCHANGEDFILE = 0;
  284. X   }
  285. X   if (logfile == NULL) {
  286. X      logfile = fopen(fakelogfile, "a");
  287. X   }
  288. X
  289. X   if (logfile != NULL) {
  290. X      (void) time(&clock);
  291. X      (void) strcpy(buffer, ctime(&clock));
  292. X      *index(buffer, '\n') = ' ';
  293. X      (void) fputs(buffer, logfile);
  294. X      (void) fprintf(logfile, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  295. X      (void) fflush(logfile);
  296. X   }
  297. X#endif
  298. X
  299. X}
  300. X
  301. X/*************************************************************************/
  302. X/* FUNCTION  : logerr                                                    */
  303. X/* PURPOSE   : Log an error to syslog                                    */
  304. X/* ARGUMENTS : Message to log, and message parameters                    */
  305. X/*************************************************************************/
  306. X
  307. Xvoid
  308. Xlogerr(message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS1*/
  309. X    char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10;
  310. X
  311. X{
  312. X
  313. X   log(LOG_ERR, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  314. X
  315. X}
  316. X
  317. X/*************************************************************************/
  318. X/* FUNCTION  : Dprintf                                                   */
  319. X/* PURPOSE   : Do COPIOUS debugging logging                              */
  320. X/* ARGUMENTS : Message to log, and message parameters                    */
  321. X/*************************************************************************/
  322. X
  323. Xvoid
  324. XDprintf(message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS1*/
  325. X    char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10;
  326. X
  327. X{
  328. X
  329. X   if (DEBUG != 0)
  330. X      log(LOG_DEBUG, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  331. X
  332. X}
  333. X
  334. X/*************************************************************************/
  335. X/* FUNCTION  : dprintf                                                   */
  336. X/* PURPOSE   : Do normal debugging logging                               */
  337. X/* ARGUMENTS : Message to log, and message parameters                    */
  338. X/*************************************************************************/
  339. X
  340. Xvoid
  341. Xdprintf(message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS1*/
  342. X    char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10;
  343. X
  344. X{
  345. X
  346. X   if (debug != 0)
  347. X      log(LOG_DEBUG, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
  348. X
  349. X}
  350. X
  351. X/*************************************************************************/
  352. X/* FUNCTION  : debug_off                                                 */
  353. X/* PURPOSE   : Increase debugging level during program execution         */
  354. X/* ARGUMENTS : none                                                      */
  355. X/*************************************************************************/
  356. X
  357. Xvoid
  358. Xdebug_on()
  359. X
  360. X{
  361. X
  362. X   if (debug) DEBUG = -1; else debug = -1;
  363. X   log(LOG_INFO, "Debugging changed to debug %s, DEBUG %s\n",
  364. X      debug ? "On" : "Off", DEBUG ? "On" : "Off");
  365. X
  366. X}
  367. X
  368. X/*************************************************************************/
  369. X/* FUNCTION  : debug_off                                                 */
  370. X/* PURPOSE   : Reduce debugging level during program execution           */
  371. X/* ARGUMENTS : none                                                      */
  372. X/*************************************************************************/
  373. X
  374. Xvoid
  375. Xdebug_off()
  376. X
  377. X{
  378. X
  379. X   if (DEBUG) DEBUG = 0; else debug = 0;
  380. X   log(LOG_INFO, "Debugging changed to debug %s, DEBUG %s\n",
  381. X      debug ? "On" : "Off", DEBUG ? "On" : "Off");
  382. X
  383. X}
  384. END_OF_FILE
  385.   if test 5400 -ne `wc -c <'log.c'`; then
  386.     echo shar: \"'log.c'\" unpacked with wrong size!
  387.   fi
  388.   # end of 'log.c'
  389. fi
  390. if test -f 'main.c' -a "${1}" != "-c" ; then 
  391.   echo shar: Will not clobber existing file \"'main.c'\"
  392. else
  393.   echo shar: Extracting \"'main.c'\" \(4631 characters\)
  394.   sed "s/^X//" >'main.c' <<'END_OF_FILE'
  395. X/*
  396. X * #include <legal/bs.h>
  397. X >
  398. X > Copyright (c) 1989 Washington University in Saint Louis, Missouri and
  399. X > Chris Myers. All rights reserved.
  400. X >
  401. X > Permission is hereby granted to copy, reproduce, redistribute or
  402. X > otherwise use this software as long as: (1) there is no monetary
  403. X > profit gained specifically from the use or reproduction of this
  404. X > software, (2) it is not sold, rented, traded, or otherwise marketed,
  405. X > (3) the above copyright notice and this paragraph is included
  406. X > prominently in any copy made, and (4) that the name of the University
  407. X > is not used to endorse or promote products derived from this software
  408. X > without the specific prior written permission of the University.
  409. X > THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  410. X > IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  411. X > WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  412. X >
  413. X */
  414. X
  415. X#include "defs.h"
  416. Xchar    *progname = "newsxd";
  417. X
  418. X/*************************************************************************/
  419. X/* FUNCTION  : main                                                      */
  420. X/* PURPOSE   :                                                           */
  421. X/* ARGUMENTS : argc and argv passed in by calling program                */
  422. X/*************************************************************************/
  423. X
  424. Xvoid
  425. Xmain(argc, argv, envp)
  426. X   int  argc;
  427. X   char *argv[], *envp[];
  428. X
  429. X{
  430. Xint     loop,
  431. X        ltime,
  432. X        clock,
  433. X    pid,
  434. X        sleeptime;
  435. X
  436. XFILE    *pidout;
  437. X
  438. Xstruct  tm      *curtime;
  439. X
  440. X   debug = 0;
  441. X   DEBUG = 0;
  442. X   newsxdebug = 0;
  443. X
  444. X   (void) strcpy(configfile, default_configfile);
  445. X   (void) strcpy(statusfile, default_statusfile);
  446. X   (void) strcpy(pidfile, default_pidfile);
  447. X#ifdef  FAKESYSLOG
  448. X   (void) strcpy(fakelogfile, FAKESYSLOG);
  449. X#endif  FAKESYSLOG
  450. X
  451. X   for (loop = 0; loop < argc; loop++) {
  452. X
  453. X      if (strcmp(argv[loop], "-v") == 0) {
  454. X         (void) fprintf(stderr, "newsxd version %1.1f", VERSION);
  455. X#if    PATCHLEVEL > 0
  456. X         (void) fprintf(stderr, "-%d", PATCHLEVEL);
  457. X#endif
  458. X         (void) fprintf(stderr, ", written by Chris Myers <chris@wugate.wustl.edu>\n");
  459. X#ifdef SYSLOG
  460. X         (void) fprintf(stderr, "Logging to syslog\n");
  461. X#endif
  462. X#ifdef FAKESYSLOG
  463. X         (void) fprintf(stderr, "Logging to %s\n", fakelogfile);
  464. X#endif
  465. X         exit(0);
  466. X      }
  467. X      if (strcmp(argv[loop], "-debug") == 0) debug++;
  468. X      if (strcmp(argv[loop], "-DEBUG") == 0) { DEBUG++; debug++; }
  469. X      if (strcmp(argv[loop], "-newsxdebug") == 0) newsxdebug++;
  470. X      if ((strcmp(argv[loop], "-c") == 0) && (loop < argc - 1))
  471. X         (void) strcpy(configfile, argv[++loop]);
  472. X      if ((strcmp(argv[loop], "-pid") == 0) && (loop < argc - 1))
  473. X         (void) strcpy(pidfile, argv[++loop]);
  474. X      if ((strcmp(argv[loop], "-status") == 0) && (loop < argc - 1))
  475. X         (void) strcpy(statusfile, argv[++loop]);
  476. X#ifdef  FAKESYSLOG
  477. X      if ((strcmp(argv[loop], "-log") == 0) && (loop < argc - 1))
  478. X         (void) strcpy(fakelogfile, argv[++loop]);
  479. X#endif
  480. X
  481. X   }
  482. X
  483. X   (void) signal(SIGCHLD, xmit_done);
  484. X   (void) signal(SIGHUP, read_config);
  485. X   (void) signal(SIGQUIT, dump_config);
  486. X   (void) signal(SIGTERM, kill_children);
  487. X   (void) signal(SIGUSR1, debug_on);
  488. X   (void) signal(SIGUSR2, debug_off);
  489. X   (void) signal(SIGIO, idle);
  490. X   (void) signal(SIGIOT, reset);
  491. X   (void) signal(SIGTRAP, dump_info);
  492. X
  493. X   (void) setuid(geteuid());
  494. X   (void) setgid(getegid());
  495. X
  496. X   if (!debug) daemon_start();
  497. X
  498. X#ifdef  SYSLOG
  499. X# ifdef LOG_LOCAL7
  500. X   openlog("newsxd", LOG_PID, SYSLOG);
  501. X# else
  502. X   openlog("newsxd", LOG_PID);
  503. X# endif
  504. X#endif
  505. X
  506. X   pidout = fopen(pidfile, "r");
  507. X   if (pidout != (FILE *) NULL) {
  508. X      (void) fscanf(pidout, "%d", &pid);
  509. X      (void) fclose(pidout);
  510. X      if (kill(pid, 0) == 0) {
  511. X         logerr("duplicate invocation of newsxd -- aborting\n");
  512. X         (void) exit(1);
  513. X      }
  514. X   }
  515. X
  516. X   log(LOG_INFO, "starting\n");
  517. X
  518. X   for (loop = 0; loop < MAXXMITTERS; loop++) {
  519. X      pidlist[loop] = 0;
  520. X      pidmap[loop] = (struct host *) NULL;
  521. X   }
  522. X
  523. X   read_config(0);
  524. X
  525. X   if (debug) dump_config();
  526. X
  527. X   pidout = fopen(pidfile, "w");
  528. X
  529. X   if (pidout != (FILE *) NULL) {
  530. X      (void) fprintf(pidout, "%d\n", getpid());
  531. X      (void) fflush(pidout);
  532. X      (void) fclose(pidout);
  533. X   }
  534. X
  535. X   while (1) {
  536. X      if (!daemon_idle) run_queue();
  537. X
  538. X      xmit_done(0);
  539. X
  540. X      (void) time(&clock);
  541. X      curtime = localtime(&clock);
  542. X      ltime = curtime->tm_sec + curtime->tm_min * 60 + curtime->tm_hour * 3600;
  543. X
  544. X      sleeptime = queueinterval - (ltime % queueinterval);
  545. X      if (sleeptime == 0) sleeptime++;
  546. X
  547. X      dprintf("%d:sleeping for %d seconds\n", ltime, sleeptime);
  548. X
  549. X      (void) sleep((unsigned) sleeptime);
  550. X
  551. X   }
  552. X}
  553. END_OF_FILE
  554.   if test 4631 -ne `wc -c <'main.c'`; then
  555.     echo shar: \"'main.c'\" unpacked with wrong size!
  556.   fi
  557.   # end of 'main.c'
  558. fi
  559. if test -f 'newsxd.conf' -a "${1}" != "-c" ; then 
  560.   echo shar: Will not clobber existing file \"'newsxd.conf'\"
  561. else
  562.   echo shar: Extracting \"'newsxd.conf'\" \(3432 characters\)
  563.   sed "s/^X//" >'newsxd.conf' <<'END_OF_FILE'
  564. X# Define transmission service classes and alternate transmitters
  565. X#     nlink    NNTPlink Transmits (Continuous NNTPXMITs)
  566. X#     high    High Priority Transmits (Top-40)
  567. X#     med    Medium Prio Transmits (Non Top-40)
  568. X#     low    Low Priority Transmits (Endnodes)
  569. X
  570. Xclass    nlink    maxxmits=99 interval=60    maxload=10  noworkfile debug=-d
  571. Xxmit    nlink    /usr/local/lib/news/nntplink nntplink -L100 %d %h:%b
  572. X
  573. Xclass    high    maxxmits=3  interval=1800  maxload=8   debug=-d
  574. X
  575. Xclass    med    maxxmits=3  interval=7200  maxload=6   nice=15    debug=-d
  576. X
  577. Xclass    low    maxxmits=2  interval=14400 maxload=4   nice=15    debug=-d
  578. X
  579. Xclass    batch    maxxmits=1  interval=14400 maxload=6   nice=15
  580. Xxmit    batch    /usr/local/lib/news/sendbatch sendbatch %f %h
  581. X
  582. X# define the default transmitter
  583. Xxmit DEFAULT /usr/local/lib/news/nntpxmit nntpxmit %d %h:%w
  584. X
  585. X# Check the transmit queue every <n> seconds (this should be at least as low
  586. X# as the smallest "interval" in all of the transmission classes).
  587. Xqueueinterval    20
  588. X
  589. X# In all of the following options, %s is replaced by the host name of the
  590. X# system being sent to.
  591. X
  592. X# File news places articles paths/ids in
  593. Xbatchfile    /usr/spool/batch/%s
  594. X
  595. X# File a news transmitter wants articles paths/ids in
  596. Xworkfile    /usr/spool/batch/%s.work
  597. X
  598. X# Where to log the output of a news transmitter (default is /dev/null)
  599. X# xmitlogs    /tmp/paramlog
  600. X
  601. X# Hosts to send news to.  Each line is of the format:
  602. X#                               CLASS   VALID XMIT
  603. X# host HOSTNAME            NAME        TIMES       OPTIONS
  604. X
  605. Xhost cec2            high    Any    
  606. Xhost dinorah            high    Any
  607. Xhost gauss            low    Any           
  608. Xhost wubios            high    Any    
  609. Xhost wuche2                     high    Any            
  610. Xhost wuibc                      low    Any
  611. Xhost wuphys            low    Any           
  612. X# host sbctri.sbc.com        low    Any           
  613. Xhost brazos.rice.edu        low    Any           
  614. Xhost kuhub.cc.ukans.edu         nlink   Any
  615. X# host wums2            low    Any    flags=-D
  616. Xhost rouge.usl.edu        low    Any
  617. Xhost husc6.harvard.edu        med    Any            
  618. Xhost swbatl.sbc.com        med     Any        
  619. Xhost dogie.macc.wisc.edu        high    Any            
  620. Xhost emory.mathcs.emory.edu     high    Any            
  621. Xhost eddie.mit.edu              high    Any            
  622. Xhost decwrl.dec.com        nlink   Any flags=-C200
  623. Xhost mailrus.cc.umich.edu    nlink   Any flags=-C200
  624. Xhost nigel.ee.udel.edu          nlink   Any flags=-C200
  625. Xhost psuvax1.cs.psu.edu        nlink   Any flags=-C200
  626. Xhost rex.cs.tulane.edu        nlink   Any flags=-C200
  627. Xhost s.ms.uky.edu        nlink   Any flags=-C200
  628. Xhost uwm.edu            nlink   Any flags=-C200
  629. Xhost tness7.sbc.com        nlink    Any flags=-C200
  630. Xhost uunet.uu.net        nlink   Any flags=-C1000000
  631. Xhost bu.edu            nlink   Any flags=-C200
  632. Xhost usc.edu                    nlink   Any flags=-C200
  633. Xhost zaphod.mps.ohio-state.edu    nlink   Any flags=-C200
  634. Xhost cs.utexas.edu        nlink   Any flags=-C200
  635. Xhost brutus.cs.uiuc.edu        nlink    Any flags=-C200
  636. Xhost wums2            batch   Any flags=-s500000
  637. Xhost dranet                     batch   Any flags=-s250000
  638. Xhost biolgy                     batch   Any flags=-s500000
  639. Xhost crygtw            batch   SaSu|Wk1730-730 flags=-s250000|-c
  640. Xhost jgaltstl                   batch   SaSu|Wk1730-730 flags=-c|-s250000|-m10000000
  641. Xhost plus5                      batch   SaSu|Wk1730-730 flags=-c|-s250000|-m10000000
  642. Xhost slustl                     batch   SaSu|Wk1730-730 flags=-c|-s250000|-m10000000
  643. Xhost hpuslma                    batch   SaSu|Wk1730-730 flags=-c|-s250000|-m10000000
  644. Xhost hilco2                     batch   SaSu|Wk1730-730 flags=-c|-s250000|-m10000000
  645. END_OF_FILE
  646.   if test 3432 -ne `wc -c <'newsxd.conf'`; then
  647.     echo shar: \"'newsxd.conf'\" unpacked with wrong size!
  648.   fi
  649.   # end of 'newsxd.conf'
  650. fi
  651. if test -f 'newsxd.h' -a "${1}" != "-c" ; then 
  652.   echo shar: Will not clobber existing file \"'newsxd.h'\"
  653. else
  654.   echo shar: Extracting \"'newsxd.h'\" \(3723 characters\)
  655.   sed "s/^X//" >'newsxd.h' <<'END_OF_FILE'
  656. X/*
  657. X * USER CONFIGURABLE OPTIONS
  658. X */
  659. X
  660. X#define    default_configfile    "/usr/local/etc/newsxd.conf"
  661. X#define    default_pidfile        "/usr/tmp/newsxd.pid"
  662. X#define    default_statusfile    "/usr/tmp/newsxd.status"
  663. X
  664. X/*
  665. X * If you run CNEWS, enable CNEWS-compatible locking by defining the
  666. X * CNEWSLOCKING symbol.  If you don't do this, there is a race condition
  667. X * than can result in some articles not being transmitted
  668. X *
  669. X * If CNEWSLOCKING is enabled, after renaming the batch file to the work file,
  670. X * each transmitter attempts to lock and then immediately unlock the news
  671. X * system to ensure that relaynews is no longer writing into the batch file.
  672. X */
  673. X
  674. X#define CNEWSLOCKING
  675. X
  676. X/*
  677. X * CNEWS sites will probably want to define default_workfile and
  678. X * default_batchfile in the following manner:
  679. X *
  680. X * #define default_batchfile    "/usr/spool/out.going/%s/togo"
  681. X * #define default_workfile    "/usr/spool/out.going/%s/togo.work"
  682. X */
  683. X
  684. X#define    default_batchfile    "/usr/spool/batch/%s"
  685. X#define    default_workfile    "/usr/spool/batch/%s.work"
  686. X
  687. X#define    default_xmitlogs    "/dev/null"
  688. X
  689. X/*
  690. X * MAXXMITTERS is the maximum number of transmitters that newsxd will
  691. X * support.  MAXCLASSXMITTERS is used to define the dimensions of an array
  692. X * used to quickly map PIDs back to particular transmitters.
  693. X */
  694. X
  695. X#define MAXXMITTERS        200
  696. X#define MAXCLASSXMITTERS    100
  697. X
  698. X/*
  699. X * Define SYSLOG if you want logging via syslog.  If so, define SYSLOG to
  700. X * the facility to log at as defined in <syslog.h>.  This is usually 
  701. X * something like LOG_NEWS or LOG_LOCAL7.
  702. X *
  703. X * If your system doesn't support syslog or you don't want to use syslog,
  704. X * you can have newsxd log to a file instead by defining FAKESYSLOG to be
  705. X * the name of the file to log to.
  706. X *
  707. X * If you are planning on turning on debugging while newsxd is running (by
  708. X * using SIGUSR1), you should STRONGLY CONSIDER using FAKESYSLOG.  Enabling
  709. X * one level of debugging can log several MBytes/hour of debugging info and
  710. X * enabling full debugging will easily triple that amount.  This will do bad
  711. X * things to your syslogd!
  712. X *
  713. X * DO NOT DEFINE BOTH SYSLOG AND FAKESYSLOG
  714. X *
  715. X */
  716. X
  717. X/* #define    SYSLOG            LOG_NEWS    /* normal syslog */
  718. X#define FAKESYSLOG        "/usr/tmp/newsxd.log"    /* fake log file */
  719. X
  720. X/*
  721. X * Things you probably shouldn't change unless modifying newsxd
  722. X */
  723. X
  724. X#define    MAXCLASSFLAGS        2    /* number of defined class flags */
  725. X#define    MAXEXECARGS        16    /* max number of args to execv */
  726. X
  727. X#define MAXTIMENAMELEN        40    /* max len of UUCP L.sys-style time */
  728. X#define    MAXCLASSNAMELEN        8    /* max length of a class name */
  729. X
  730. X#define    C_NOWORK        0    /* Don't rename batchfile->workfile */
  731. X#define    C_NOBATCH        1    /* Don't look for batchfile */
  732. X
  733. X/*
  734. X * Why isn't a transmitter running (used in status display)
  735. X */
  736. X
  737. X
  738. Xstatic char *wnlist[] = {
  739. X               "TTL Penlty",
  740. X#define WN_PENALTYTIME        0    /* host went over ttl, now penalized */
  741. X               "TTL Kill",
  742. X#define WN_TTL            1    /* host hit ttl, killed xmit */
  743. X               "Class Intv",
  744. X#define WN_CLASSSTARTINT    2    /* started xmit this class recently */
  745. X               "Host Intvl",
  746. X#define WN_HOSTSTARTINT        3    /* started xmit this host recently */
  747. X               "High Load",
  748. X#define WN_LOAD            4    /* load too high */
  749. X               "Wrong Time",
  750. X#define WN_BADTIME        5    /* wrong time to xmit */
  751. X               "Max Xmits",
  752. X#define WN_MAXXMITS        6    /* too many transmitters running */
  753. X               "RUNNING",
  754. X#define WN_RUNNING        7    /* it's running! */
  755. X               "No Work",
  756. X#define WN_NOWORK        8    /* no work to transmit */
  757. X               "Bad Rename",
  758. X#define WN_RENAMEFAILED        9    /* couldn't rename batch -> workfile */
  759. X               "NotMyTurn",
  760. X#define WN_NOTMYTURN        10    /* give other host a chance to xmit */
  761. X               "No Slot!"
  762. X#define WN_NOSLOT        11    /* no class slot, recompile newsxd */
  763. X};
  764. END_OF_FILE
  765.   if test 3723 -ne `wc -c <'newsxd.h'`; then
  766.     echo shar: \"'newsxd.h'\" unpacked with wrong size!
  767.   fi
  768.   # end of 'newsxd.h'
  769. fi
  770. echo shar: End of archive 3 \(of 3\).
  771. cp /dev/null ark3isdone
  772. MISSING=""
  773. for I in 1 2 3 ; do
  774.     if test ! -f ark${I}isdone ; then
  775.     MISSING="${MISSING} ${I}"
  776.     fi
  777. done
  778. if test "${MISSING}" = "" ; then
  779.     echo You have unpacked all 3 archives.
  780.     rm -f ark[1-9]isdone
  781. else
  782.     echo You still must unpack the following archives:
  783.     echo "        " ${MISSING}
  784. fi
  785. exit 0
  786. exit 0 # Just in case...
  787.